home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / comm / yep16.zip / YX-13.ZIP / ROT13.CMD < prev    next >
OS/2 REXX Batch file  |  1996-11-20  |  859b  |  38 lines

  1. /* simple ROT13 encode/decode a file from stdin to stdout
  2.  
  3. usage: rot13 <input.txt >output.txt
  4.  
  5. */
  6.  
  7. if lines() = 0 then do
  8.     say sourceline(3)
  9.     exit
  10. end
  11.  
  12. do while lines() > 0
  13.     say translate(linein(),'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
  14.  
  15. /* commented out below is the standard way of doing it. I had forgotten about
  16.  the handy REXX "translate" function which speeds things up greatly! */
  17.     
  18. /*    t = ''
  19.     l = linein()
  20.     do x = 1 to length(l)
  21.         c = substr(l,x,1);
  22.     if ((c>='a')&(c<='z'))|((c>='A')&(c<='Z')) then do
  23.         d = c2d(c)
  24.         select
  25.         when d>=110 then d = d - 13
  26.         when d>=97 then d = d + 13
  27.         when d>=78 then d = d - 13
  28.         otherwise d = d + 13
  29.         end
  30.         c = d2c(d)
  31.     end
  32.     t = t || c
  33.     end;  
  34.     say t */
  35. end;
  36.  
  37.  
  38.